<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
?>
<style type="text/css">
	.list-dot-othors li{width: 16%;}
</style>
<?php 
    $sname_self_flag = true;#检测当前source_name是否在系统的来源名称库里
    $ssname_all = array();#所有的来源名称
    if($source_name){//如果当前source_name不为空则进行判断
        foreach($this->setting as $v){
            $ssname_all[]=$v['source_name'];
        }
        if (in_array($source_name, $ssname_all)){
            $sname_self_flag=false;
        }
        unset($ssname_all);
    }
?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>content_addtop_new.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>colorpicker.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>hotkeys.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script language="javascript">
function ValidateValue(textbox) {
	var IllegalString = "[`~!#$^&*()=|{}':;'\\[].<>/?~#";
	var textboxvalue = textbox.value;
	var index = textboxvalue.length - 1;
	 
	var s = textbox.value.charAt(index);
	 
	if (IllegalString.indexOf(s) > 0) {
		alert('非法字符：'+s);
		s = textboxvalue.substring(0, index);
		textbox.value = s;
		return false;
	}
}
<!--
	$(function(){
		$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
		$("#title").formValidator({onshow:"请输入标题",onfocus:"请输入标题",oncorrect:"正确"}).inputValidator({min:1,onerror:"请输入标题"});
	})
//-->

$(function(){
	$('#s_sname').change(function(){
		var source_name = $(this).val();
	    if(source_name=="yes"){  
	        $('#self_sname').css('display','block');
	        $('#self_sname').focus();
	    }else if(source_name=="no"){ 
	        //alert('no');
	        $('#self_sname').css('display','none');
	    } 
	})
})

function close_dialog(dialog_id){
	var list = art.dialog.list;
	for (var i in list) {
	    list[i].close();
	};
}
</script>
<form action="?m=<?php echo ROUTE_M;?>&c=<?php echo ROUTE_C;?>&a=<?php echo ROUTE_A;?>&id=<?=$id?>&source_type=<?=$source_type?>" method="post" name="myform" id="myform">
<div class="pad-10">
		<div class="col-tab">
			<div id="div_setting_1" class="contentList pad-10">
<table cellpadding="2" cellspacing="1" class="table_form" width="100%">
	<tr>
		<th width="100"><?php echo L('title')?> :</th>
		<td colspan="5">
			<input name="picture[title]" id="title" class="input-text" value="<?=$title?>" type="text" size="40" onkeyup="ValidateValue(this)">
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('keywords')?> :</th>
		<td colspan="5">
			<input name="picture[keywords]" id="keywords" class="input-text" value="<?=$keywords?>" type="text" size="40" onkeyup="ValidateValue(this)">
			<span style="color: red;font-size:18px;"><strong>注意：</strong>多关键字之间用英文","隔开</span>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('type')?>：</th>
		<td colspan="5">
			<select name="picture[type_id]" >
				<option value="0">请选择</option>
				<?php echo $types;?>
			</select>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('contestName')?> :</th>
		<td colspan="5">
			<select name="contestid" >
				<option value="0">请选择</option>
				<?php echo $categorys;?>
			</select>
		</td>
	</tr>
	<tr>
		<th width="200"><?php echo L('source_name')?>：</th>
		<td colspan="5"><select name="picture[source_name]" id="source_name">
			<option value="" selected="">请选择</option>
			<?php foreach($this->setting as $v){?>
			<option value="<?php echo $v['source_name'];?>" <?php if ($v['source_name'] == $source_name){?> selected <?php }?>><?php echo $v['source_name'];?></option>
			<?php }?>
			</select>
			<?php echo form::select(array('2'=>'外部采集', '1'=>'站内添加'), $source, 'name="picture[source]"')?>
								&nbsp;&nbsp;是否编辑<b>来源名称</b>：<select name='picture[sname_manual_flag]' id='s_sname'>
								    <option value='no'>否</option>
								    <option value='yes'<?php if ($sname_self_flag) {
								        echo 'selected';
								    }?>>是</option>
								</select>&nbsp;<span style='color:red;font-weight:bold;'>来源名称如需手动输入，请选择"是"；默认为"否"！</span><br><input style='display:<?php echo $sname_self_flag?'block':'none'?>;' type='text' name='picture[sname_manual]' id='self_sname' placeholder='请在此输入要编辑的来源名称...' size=30 value='<?=$source_name?>'>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('source_link')?> :</th>
		<td colspan="5">
			<input name="picture[source_link]" class="input-text" id="source_link" value="<?=$source_link?>" type="text" size="40">
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo '是否发布';?> :</th>
		<td colspan="5"><?php echo form::radio(array('1'=>'发布','0'=>'未发布'),$is_publish,'name="picture[is_publish]"')?></td>
	</tr>
	<tr>
		<th width="100"><?php echo L('image_small')?> :</th>
		<td style=>
			<?php echo form::images_crop('picture[image_small]', 'image_small', $image_small)?>
			<br>注意：<span style="color:red">APP版本要求，图集角标宽高为100*100</span>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('image_smalls')?> :</th>
		<td style=>
			<?php echo form::images_crop('picture[image_cover]', 'image_cover', $image_cover)?>
		</td>
		<th width="70">竖形图 :</th>
		<td colspan="3">
			<?php echo form::images_crop('picture[image_vertical]', 'image_vertical', $image_vertical)?>
		</td>
	</tr>
	<tr>
		<th width="100">正方图一:</th>
		<td>
			<?php echo form::images_crop('picture[image_square1]', 'image_square1', $image_square1)?>
		</td>
		<th width="70">正方图二:</th>
		<td>
			<?php echo form::images_crop('picture[image_square2]', 'image_square2', $image_square2)?>
		</td>
		<th width="70">正方图三:</th>
		<td>
			<?php echo form::images_crop('picture[image_square3]', 'image_square3', $image_square3)?>
		</td>
	</tr>
	<tr>
		<th width="100"><span style="font_size:20px">注意</span> :</th>
		<td>
			<span style="color:red">APP版本要求，正方形图宽高为700*700</span>
		</td>
	</tr>
	<tr>
		<th><?php echo L('description')?> :</th>
		<td colspan="5"><textarea name="picture[description]" id="description" cols="60"rows="6"><?=$description?></textarea>
		<?php echo form::editor('description','full','','','',1,1)?>
		</td>
	</tr>
	<tr>
		<th>组图 :</th>
		<td colspan="5">
			<input name="info[pictureurls]" type="hidden" value="1">
			<fieldset class="blue pad-10">
	        <legend>图片列表</legend><center><div class="onShow" id="nameTip">您最多可以同时上传 <font color="red">50</font> 张</div></center>
	        <div id="pictureurls" class="picList">
	        	<?php foreach ($pictureurls as $k => $v) {?>
	        	<li id="image<?=$k?>"><input type="text" name="pictureurls_url[]" id="pictureurls_url_<?php echo $k;?>" value="<?=$v->url?>" style="width:500px;height:30px;" ondblclick="image_priview(this.value);" class="input-text"  onmouseover="image_priview_new(this.value,<?php echo $k;?>);" readonly="true" onmouseout="close_dialog(this.id);"> <br><input type="text" name="pictureurls_alt[]" value="<?=$v->alt?>" style="width:400px;" class="input-text" placeholder="请输入该图片的注解，注解必须包含中文字符，否则注解将被置为空！"> <a href="javascript:image_priview('<?=$v->url?>');">预览</a>&nbsp;|&nbsp;<a href="javascript:remove_div('image<?=$k?>')">移除</a> </li>
	        	<?php }?>
	        </div>
			</fieldset>
			<div class="bk10"></div>
			<div class="picBut cu"><a href="javascript:void(0);" onclick="javascript:flashupload('pictureurls_images', '附件上传','pictureurls',change_images,'50,gif|jpg|jpeg|png|bmp,1','content','11','<?php echo upload_key('50,gif|jpg|jpeg|png|bmp,1');?>')"> 选择图片 </a></div>
		</td>
	</tr>

<tr>
		<th></th>
		<td colspan="5">
		<!-- <input name="dosubmit" type="submit"  id="dosubmit"  value="<?php echo L('submit')?>" ></td> -->
	</tr>

</table>
</div></div></div>
<div class="fixed-bottom">
	<div class="fixed-but text-c">
    <div class="button"><input value="保存并关闭" type="submit" name="dosubmit" class="cu" style="width:145px;" onclick="refersh_window()"></div>
    <div class="button"><input value="关闭(X)" type="button" name="close" onclick="refersh_window();close_window();" class="cu" style="width:70px;"></div>
      </div>
</div>
</form>
</body>
</html>
<script language="javascript" type="text/javascript">
function AdsType(adstype) {
	$('#SizeFormat').css('display', 'none');
	if(adstype=='0') {
		
	} else if(adstype=='1') {
		$('#SizeFormat').css('display', '');
	}
}
$('#AlignBox').click( function (){
	if($('#AlignBox').attr('checked')) {
		$('#PaddingLeft').attr('disabled', true);
		$('#PaddingTop').attr('disabled', true);
	} else {
		$('#PaddingLeft').attr('disabled', false);
		$('#PaddingTop').attr('disabled', false);
	}
});
<!--
//只能放到最下面
var openClose = $("#RopenClose"), rh = $(".addContent .col-auto").height(),colRight = $(".addContent .col-right"),valClose = getcookie('openClose');
$(function(){
	if(valClose==1){
		colRight.hide();
		openClose.addClass("r-open");
		openClose.removeClass("r-close");
	}else{
		colRight.show();
	}
	openClose.height(rh);
	
/*
 * 加载禁用外边链接
 */

	$('#linkurl').attr('disabled',true);
	$('#islink').attr('checked',false);
	$('.edit_content').hide();
	jQuery(document).bind('keydown', 'Alt+x', function (){close_window();});
})
document.title='<?php echo L('add_content');?>';
self.moveTo(-4, -4);
function refersh_window() {
	setcookie('refersh_time', 1);
}
openClose.click(
	  function (){
		if(colRight.css("display")=="none"){
			setcookie('openClose',0,1);
			openClose.addClass("r-close");
			openClose.removeClass("r-open");
			colRight.show();
		}else{
			openClose.addClass("r-open");
			openClose.removeClass("r-close");
			colRight.hide();
			setcookie('openClose',1,1);
		}
	}
)
//--> 
</script>

<script language="javascript">
	$(function(){
		$('#source_name').change(function(){
			var source_name = $(this).val();
			if (!source_name) {
				$('#source_link').attr('value','');$('#source_link').attr('readonly', false);return false;
			}
			$.ajax({
				type:"get",
				url:"?m=picture&c=picture&a=ajaxSourceLink&pc_hash=<?php echo $_SESSION['pc_hash'];?>&source_name="+source_name,
				dataType: "json",
				success:function(data){
					if(data['status']){
						$('#source_link').attr('value',data['source_link']);
						$('#source_link').attr('readonly', true);
					}
				}
			})
		})
	})
</script>